<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body {
        margin: 0;
      }
      img {
        display: block;
        margin: 0 auto;
      }
    </style>
  </head>
  <body>
    <h1>Hello</h1>
    <img
      src="https://t7.baidu.com/it/u=2529476510,3041785782&fm=193&f=GIF"
      alt=""
      width="400"
    />
    <script src="./js/html2canvas.js"></script>
    <script>
      window.addEventListener("click", () => {
        new html2canvas(document.body, {
          allowTaint: true,
          useCORS: true,
        }).then((cvs) => {
          cvs.toBlob((blob) => {
            let f = new Blob([blob]);
            let link = document.createElement("a");
            link.download = "a.png";
            link.href = URL.createObjectURL(f);
            link.click();
          }, "image/png");
        });
      });
    </script>
  </body>
</html>
